<template>
	<view class="">
		<!-- 年 -->
		<view class="year" v-if="type === 'year'">
			<picker mode="date" fields='year' :value="curTime">
				<view class="uni-input">{{showTime}}</view>
			</picker>
		</view>
		<!-- 年月 -->
		<view class="month" v-if="type === 'year'">

		</view>
		<!-- 年月日 -->
		<view class="date" v-if="type === 'year'">
			ri
		</view>
		<!-- 时间 -->
		<view class="time" v-if="type === 'year'">

		</view>
		<!-- 年段 -->
		<view class="year-cut" v-if="type === 'year'">

		</view>
		<!-- 年月段 -->
		<view class="month-cut" v-if="type === 'year'">

		</view>
		<!-- 时间段 -->
		<view class="time-cut" v-if="type === 'year'">

		</view>
		<!-- 完整时间 年月日 时分秒 -->
		<view class="defalut" v-if="type === 'year'">

		</view>
		<!-- 完整时间段 年月日 时分秒 -->
		<view class="defalut-cut" v-if="type === 'year'">

		</view>
	</view>
</template>

<script>
	import {
		formatDate
	} from './time.js'
	export default {
		props: {
			// 选择器类型：year,month,date,time,year-cut,month-cut,time-cut
			type: {
				type: String,
				default: () => 'defalut'
			},
			// 绑定值的格式化
			valueFormat: {
				type: String,
				default: () => ''
			},
			// 显示值的格式化
			viewFormat: {
				type: String,
				default: () => null
			},
			value: {
				type: [Date, Array],
				default: () => ''
			}
		},
		data() {
			return {
				curTime: null,
				format: ''
			}
		},
		computed: {
			// 显示的时间
			showTime() {
				if (this.viewFormat) {
					return formatDate(this.valuethis.viewFormat)
				}
			}
		},
		created() {
			if (this.type.includes('cut')) {
				this.curTime = []
			} else {
				this.curTime = formatDate()
			}
		}
	}
</script>

<style>
</style>
